import * as rpc from 'vscode-jsonrpc/lib/node/main.js';

console.log('服务器启动中...');

let connection = rpc.createMessageConnection(
	new rpc.StreamMessageReader(process.stdin),
	new rpc.StreamMessageWriter(process.stdout));

let notification = new rpc.NotificationType('testNotification');

// 添加连接错误处理
connection.onError((error) => {
    console.error('服务器连接错误:', error);
});

connection.onClose(() => {
    console.log('服务器连接已关闭');
    process.exit(0);
});

connection.onNotification(notification, (param) => {
	console.log('收到通知:', param); // 这会打印 Hello World
});

console.log('服务器开始监听...');
connection.listen();